<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{padding: 0;margin: 0;}
        
        li{
            list-style: none;
            line-height: 40px;
            border: 1px dashed #333;
        }
        .list{
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <button class="delEle">删除元素</button>
        <ul class="list">
            <li class="first">01</li>
            <li>02</li>
            <li class="mid">03</li>
            <li>04</li>
            <li>05</li>
            <li class="last">06</li>
        </ul>
    </div>
   
</body>
<script>
    var ul = document.querySelector(".list");
    var mid = document.querySelector(".mid");  
    var delEle = document.querySelector(".delEle");

    // 节点的删除 

    // Element.remove()    自删

    // parentNode.removeChild(childNode) 父删(父节点统筹 -> 父删子)


    // 点击按钮 => 删除 mid
    delEle.onclick = function(){
        console.log(mid);

        // 自删
        // mid.remove();

        // if(mid){
        //     mid.remove();
        //     mid = null;
        // }

        // 父删
        if(mid){
            ul.removeChild(mid);
            mid = null;
        }
    }


  




</script>
</html>